package main

import (
	"fmt"
	"math"
	"time"
)

func main() {
	endDay := time.Now()
	fmt.Println(endDay)
	startDay := endDay.Add(time.Duration(-1*14+1) * time.Hour * 24)
	endDay = time.Now().Add(time.Duration(-1*7) * time.Hour * 24)
	list := GetDaysWithTimeRever(startDay, endDay, "20060102")
	fmt.Println("startDay", startDay)
	fmt.Println("endDay", endDay)
	fmt.Println(list)
}



func GetDaysWithTimeRever(start time.Time, end time.Time, layout string) []string {
	hours := end.Sub(start).Hours()
	days := hours / 24
	cha := int(math.Ceil(days))
	daylist := make([]string, 0)
	for i := 0; i <= cha; i++ {
		day := end.Add(24 * time.Hour * time.Duration(-1*i))
		daylist = append(daylist, day.Format(layout))
	}

	return daylist
}